package com.cet.designpatterns.iterator;

import java.util.Iterator;
import java.util.List;

/**
 * @program: algorithm
 * @description:
 * @author: 陈恩涛
 * @create: 2021-09-22 09:29
 **/
public class OutputImpl {

    private List<College> collegeList;

    public OutputImpl(List<College> collegeList) {
        this.collegeList = collegeList;
    }

    public void printCollege() {
        for (College college : collegeList) {
            System.out.println("=================" + college.getName() + "===========");
            printDepartment(college.createIterator());
        }
    }

    private void printDepartment(Iterator iterator) {
        while (iterator.hasNext()) {
            Department department = (Department) iterator.next();
            System.out.println(department.getName());
        }
    }
}
